<template>
    <div class="org-li">
        <div class="org-info">
            <div class="org-title"><i class="fa fa-building-o"></i>{{org.departmentName}}<div style="display: inline-block;"><button class="btn-qrcode" @click="qrCodeShow(org)" v-res="menu_0010_0005"><i class="fa fa-qrcode" aria-hidden="true"></i></button></div></div>
            <div class="company-code"><i class="fa fa-laptop"></i>公司码:{{org.companyCode}}</div>
        </div>
        <div class="org-action">
            <div v-res="menu_0010_0003" style="width: 50%;float: left;"><button class="button-small" @click="editOrg(org.id)" >编辑</button></div>
            <div v-res="menu_0010_0004" style="float: left;"><button class="button-small" @click="deleteOrg(org.id)" >删除</button></div>
        </div>
        <div class="clearfix"></div>
        <QRCode  v-bind:qrcode="qrcodeNode" ref="qrCode"></QRCode>
    </div>
</template>

<script>
    import {MessageBox,Toast } from 'mint-ui';
    import QRCode from '../base/QRCode.vue'
    export default {
        name: "org-list-detail",
        props: ['org'],
        components:{MessageBox,QRCode},
        mounted(){

        },
        data(){
            return{
                qrcodeNode:{}
            }
        },
        methods:{
            editOrg(id){
                this.$router.push({name:'OrgEdit',params:{id:id}});
            },
            deleteOrg(id){
                MessageBox.confirm('确定删除机构?').then(action => {
                    this.deleteAction(id);
                });
            },
            deleteAction(id){
                var _self = this;
                var body = {};
                body.params = {id:id};
                var url = this.utilHelper.apiUrl + '/api/delDept';
                this.$http.post(url,body).then((response)=>{
                    var body = response.body;
                    var resData = body.resData;
                    if(1 == resData.result){
                        Toast('操作成功');
                        _self.$emit('optOrgListener');
                    }else if(0 == resData.result){
                        Toast(resData.resultMsg);
                    }
                });
            },
            qrCodeShow(org){
                this.qrcodeNode.orgId = this.org.departmentCode;
                this.qrcodeNode.orgName = this.org.departmentName;
                console.log( this.qrcodeNode,888);
                this.$refs.qrCode.useqrcode();
                $("#qrCode").show();

            }
        }
    }
</script>

<style scoped>
    .org-li{padding:10px 0;border-bottom: 1px solid #C9C5C5;background: #FFF;line-height: 25px;}
    .org-li i{color:#65baf5;margin-right: 10px;}
    .org-info{float:left;width: 60%;padding-left:10px;}
    .org-title{font-size:16px;}
    .company-code{font-size:14px;color: #ff962e}
    .org-action{float:left;width: 40%;text-align: center;line-height: 40px;}
    .btn-qrcode{background: none;border: none;color: #FF1400;margin-left:10px;}
    .btn-qrcode i{color: #FF1400;}
</style>